package com.xm.servlet.background.commodity;

import com.xm.service.background.CommodityService;
import lombok.SneakyThrows;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 修改图片名称
 * @author 康文程
 * @date 2024-1-16 下午 12:37
 */
@WebServlet("/background/update/commodity/image/name")
public class UpdateCommodityImageNameServlet extends HttpServlet {
    /**
     * 商品Service
     */
    private final CommodityService service = new CommodityService();

    @SneakyThrows
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String newImagesName = req.getParameter("newCommodityImageName");
        String commodityId = req.getParameter("commodityId");
        resp.getWriter().print(service.updateCommodityImgNameById(Integer.parseInt(commodityId),newImagesName));
    }
}
